package euler;

import java.math.BigInteger;

public class Problem {

	public Problem() {
		
	}
	
	public void run() {
		System.out.println("check Problems");
		
		System.out.println("2^1000->Ziffernsumme="+ziffernSumme(power(2,1000).toString()));
		
		System.out.println("100!->ZiffernSumme="+ziffernSumme(factorial(100).toString()));
		
	}
	
	public long ziffernSumme(String ziffStr) {
		long ziffSum=0;
		for (int strIdx=0;strIdx<ziffStr.length();strIdx++) {
			ziffSum=ziffSum+Integer.parseInt(ziffStr.substring(strIdx, strIdx+1));
		}
		return ziffSum;
	}
	
	public BigInteger power(int base, int exponent) {		
		return BigInteger.valueOf(base).pow(exponent);
	}
	
	public BigInteger factorial(int n) {	
		BigInteger factorial = BigInteger.valueOf(1);
		
		for (int i=1;i<=n;i++) factorial=factorial.multiply(BigInteger.valueOf(i));
		return factorial;
	}
}
